package GUI;

import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import java.awt.Font;
import java.util.ArrayList;

/**this class open a new window with list of messages to librarian about readers that extended
 * their loans*/
public class GUI_DisplayMsgs extends JFrame{
	/**table JTable to display messages*/
	private JTable table;
	
	/**@param msgs ArrayList<String[]> of messages*/
	public GUI_DisplayMsgs(ArrayList<String[]> msgs) {
		getContentPane().setLayout(null);
		this.setSize(700, 600);
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(37, 61, 637, 333);
		getContentPane().add(scrollPane);
		
		table = new JTable(msgs.size(),1);
		table.getColumnModel().getColumn(0).setHeaderValue("");
		for(int i=0;i<msgs.size();i++)
		{
			table.setValueAt(msgs.get(i)[0],i,0);
		}
		scrollPane.setViewportView(table);
		
		JLabel label = new JLabel("Notifications about extended loans:");
		label.setFont(new Font("Tahoma", Font.BOLD, 14));
		label.setBounds(38, 11, 320, 32);
		getContentPane().add(label);
		this.setVisible(true);
	}
}
